/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * Entidade Rota
 */
@XmlRootElement
@Entity
@Table(name = "rota", catalog = "agenciadeviagem", schema = "")
@NamedQueries(
  {
    @NamedQuery(name = "Rota.findAll", query = "SELECT r FROM Rota r"),
    @NamedQuery(name = "Rota.findByNome", query = "SELECT r FROM Rota r WHERE r.nome = :nome"),
    @NamedQuery(name = "Rota.findByOrigem", query = "SELECT r FROM Rota r WHERE r.origem = :origem"),
    @NamedQuery(name = "Rota.findByDestino", query = "SELECT r FROM Rota r WHERE r.destino = :destino"),
    @NamedQuery(name = "Rota.findByDescricao", query = "SELECT r FROM Rota r WHERE r.descricao = :descricao"),
    @NamedQuery(name = "Rota.findNameRota", query = "SELECT r FROM Rota r WHERE r.destino = :destino and  r.origem = :origem"),
    @NamedQuery(name = "Rota.findAllOrigem", query = "SELECT r.origem FROM Rota r group by r.origem order by r.origem"),
    @NamedQuery(name = "Rota.findAllDestino", query = "SELECT r.destino FROM Rota r group by r.destino order by r.destino")
  }
)
public class Rota implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "nome", nullable = false, length = 20)
    private String nome;
    @Column(name = "origem", length = 20)
    private String origem;
    @Column(name = "destino", length = 20)
    private String destino;
    @Column(name = "descricao", length = 60)
    private String descricao;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rotanome")
    private Collection<Passagem> passagemCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rotanome")
    private Collection<RotaHasCompania> rotaHasCompaniaCollection;

    /**
     * Rota
     */
    public Rota() {
    }

    /**
     *
     * @param nome
     */
    public Rota(String nome) {
        this.nome = nome;
    }

    /**
     *
     * @return String
     */
    public String getNome() {
        return nome;
    }

    /**
     *
     * @param nome
     */
    public void setNome(String nome) {
        this.nome = nome;
    }

    /**
     *
     * @return String
     */
    public String getOrigem() {
        return origem;
    }

    /**
     *
     * @param origem
     */
    public void setOrigem(String origem) {
        this.origem = origem;
    }

    /**
     *
     * @return String
     */
    public String getDestino() {
        return destino;
    }

    /**
     *
     * @param destino
     */
    public void setDestino(String destino) {
        this.destino = destino;
    }

    /**
     *
     * @return String
     */
    public String getDescricao() {
        return descricao;
    }

    /**
     *
     * @param descricao
     */
    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    /**
     *
     * @return Collection
     */
    public Collection<Passagem> getPassagemCollection() {
        return passagemCollection;
    }

    /**
     *
     * @param passagemCollection
     */
    public void setPassagemCollection(Collection<Passagem> passagemCollection) {
        this.passagemCollection = passagemCollection;
    }

    /**
     *
     * @return Collection
     */
    public Collection<RotaHasCompania> getRotaHasCompaniaCollection() {
        return rotaHasCompaniaCollection;
    }

    /**
     *
     * @param rotaHasCompaniaCollection
     */
    public void setRotaHasCompaniaCollection(Collection<RotaHasCompania> rotaHasCompaniaCollection) {
        this.rotaHasCompaniaCollection = rotaHasCompaniaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nome != null ? nome.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rota)) {
            return false;
        }
        Rota other = (Rota) object;
        if ((this.nome == null && other.nome != null) || (this.nome != null && !this.nome.equals(other.nome))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Rota[nome=" + nome + "]";
    }

}
